package org.elucid.gadmin.ui;

import javax.swing.table.AbstractTableModel;

public class GTableModel extends AbstractTableModel {
	
	private Object[] columnNames;
	private Object[][] rowData;
	
	public GTableModel(Object[][] rowData, Object[] columnNames) {
		super();
		this.columnNames = columnNames;
		this.rowData = rowData;
	}

	public String getColumnName(int column) {
		return columnNames[column].toString();
	}

	public int getRowCount() {
		return rowData.length;
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	public Object getValueAt(int row, int col) {
		Object value = null;
		try
		{
			if( row < rowData.length && col < rowData[row].length )
				value = rowData[row][col];
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}

	public boolean isCellEditable(int row, int column) {
		return true;
	}

	public void setValueAt(Object value, int row, int col) {
		rowData[row][col] = value;
		fireTableCellUpdated(row, col);
	}

	private static final long serialVersionUID = -130472460679117077L;
}
